Skip to content

feat(cli): honest non-interactive init — fail on skew, no false success (rc.2 M4)#687

Open
coderdan wants to merge 2 commits into
mainfrom
feat/honest-noninteractive-init
Open

feat(cli): honest non-interactive init — fail on skew, no false success (rc.2 M4)#687
coderdan wants to merge 2 commits into
mainfrom
feat/honest-noninteractive-init

Conversation

@coderdan

@coderdan coderdan commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Problem (rc.2 M4)

Non-interactive stash init reported success for setups that hadn't fully completed — so CI/agents couldn't trust its exit code or its summary. Three honesty gaps:

  1. Version skew was warn-and-proceed. A non-interactive run can't reconcile a behind skew (an installed @cipherstash/* older than this CLI expects) — it won't mutate an install without consent — so it warned and kept going, scaffolding config/client against mismatched packages, then printed "Setup complete".
  2. "Setup complete" was unconditional. Even when EQL install failed (eqlInstalled=false), the header still said complete — and "✓ Database connection verified" was printed although init only resolves a URL, never connects.
  3. "Skills loaded" was unconditional. The Claude/Codex handoff launch prompt pointed the agent at the skills dir even when installSkills() copied nothing (stripped build) — telling it to read files that aren't there.

Fix

  1. Fail on skew. Non-interactive + behind skew → refuse with a non-zero exit (CliExit(1)) and the exact align command, instead of proceeding. The npm dist-tags deliver broken/stale packages: adapters' latest=0.0.0, stack latest=0.19.0; stash init installs unpinned #661/fix(cli): pin init's installs to the release's own package versions (#661) #666 no-mutation principle is preserved (execSync still never called — only the post-warning action changes). ahead skew stays a warn (install likely fine; update the CLI). Interactive runs still offer to align.
  2. Honest summary. When EQL is required but missing (!eqlInstalled && integration !== 'prisma-next'), the summary reads "Setup incomplete" and init exits non-zero, pointing at stash eql install. "Database connection verified" → "Database URL resolved"; "Encryption client scaffolded" shows only when a client was actually written (skipped for Prisma Next).
  3. Honest skills prose. The launch-prompt skills clause is conditional on installSkills() returning something.

Scope notes

Verification

  • Updated install-deps skew tests (refuses + exit 1, still never mutates); new init-command honest-summary tests (EQL-missing → exit 1 + "Setup incomplete"; prisma-next eqlInstalled=false → completes).
  • Suite: 542 unit / 62 e2e green, code:check clean. Changeset: stash minor. Skill (stash-cli) + doc comments updated.
  • No new e2e: a full non-interactive init needs live auth + a DB (which is why there's no init e2e); the honest-summary and skew-fail logic is unit-covered.

https://claude.ai/code/session_01MxTTPaPP16m6br7Hoab94w

Summary by CodeRabbit

  • Bug Fixes

    • stash init now exits with an error when required dependencies have incompatible versions and provides an alignment command.
    • Setup reports accurately reflect whether the encryption client, EQL extension, and other components were installed.
    • Missing EQL installation now clearly reports “Setup incomplete” and directs users to install it.
    • Claude and Codex handoff messages no longer reference skills that were not installed.
  • Documentation

    • Updated stash init guidance for dependency version mismatches and incomplete EQL setup.

@coderdan
coderdan requested a review from a team as a code owner July 17, 2026 08:57
@changeset-bot

changeset-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1d245a9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
stash Minor
@cipherstash/basic-example Patch
@cipherstash/e2e Patch
@cipherstash/stack Minor
@cipherstash/stack-drizzle Minor
@cipherstash/stack-supabase Minor
@cipherstash/prisma-next Minor
@cipherstash/wizard Minor
@cipherstash/bench Patch
@cipherstash/test-kit Patch
@cipherstash/prisma-next-example Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@coderdan, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 1 minute

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5c4f9138-b360-4314-9363-ae23459bd74c

📥 Commits

Reviewing files that changed from the base of the PR and between 27520d6 and 1d245a9.

📒 Files selected for processing (11)
  • .changeset/honest-noninteractive-init.md
  • packages/cli/src/commands/impl/steps/handoff-claude.ts
  • packages/cli/src/commands/impl/steps/handoff-codex.ts
  • packages/cli/src/commands/init/__tests__/init-command.test.ts
  • packages/cli/src/commands/init/index.ts
  • packages/cli/src/commands/init/lib/__tests__/setup-prompt.test.ts
  • packages/cli/src/commands/init/lib/setup-prompt.ts
  • packages/cli/src/commands/init/steps/__tests__/install-deps.test.ts
  • packages/cli/src/commands/init/steps/install-deps.ts
  • packages/cli/src/messages.ts
  • skills/stash-cli/SKILL.md
📝 Walkthrough

Walkthrough

stash init now exits non-zero for non-interactive dependency skew and incomplete EQL setup, reports completion from actual state, preserves Prisma Next’s exception, and avoids mentioning absent agent skills in Claude and Codex handoff prompts.

Changes

Init outcome handling

Layer / File(s) Summary
Dependency skew refusal
packages/cli/src/messages.ts, packages/cli/src/commands/init/steps/install-deps.ts, packages/cli/src/commands/init/steps/__tests__/install-deps.test.ts
Non-interactive dependency skew now prints alignment commands, logs the skew message, rejects with CliExit, and avoids installation commands.
Init completion validation
packages/cli/src/commands/init/index.ts, packages/cli/src/commands/init/__tests__/init-command.test.ts, .changeset/honest-noninteractive-init.md, skills/stash-cli/SKILL.md
Completion checkmarks reflect actual state; missing EQL reports incomplete setup and exits non-zero except for Prisma Next.
Conditional agent handoff prompts
packages/cli/src/commands/impl/steps/handoff-claude.ts, packages/cli/src/commands/impl/steps/handoff-codex.ts
Skills-directory instructions are included only when skills were installed.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant initCommand
  participant installDepsStep
  participant installEqlStep
  participant AgentHandoff
  User->>initCommand: run stash init
  initCommand->>installDepsStep: install dependencies
  installDepsStep-->>initCommand: dependency state or CliExit
  initCommand->>installEqlStep: install EQL extension
  installEqlStep-->>initCommand: eqlInstalled state
  initCommand->>AgentHandoff: build prompt from installed skills
Loading

Possibly related PRs

Suggested reviewers: calvinbrewer

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main CLI change: non-interactive init now fails on skew and avoids false success.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/honest-noninteractive-init

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cli/src/commands/impl/steps/handoff-claude.ts`:
- Around line 41-48: Make all generated handoff guidance respect the
installed-skills state: in handoff-claude.ts, update the setup prompt loaded by
the launchPrompt flow so the empty-skills variant does not reference skill
directories or the unwritten AGENTS.md file, while retaining valid skill
guidance when skills exist; in handoff-codex.ts, update its generated guidance
so .codex/skills/ is omitted when installed.length is zero.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f8da61ce-6475-4788-b2d3-6295b53bb730

📥 Commits

Reviewing files that changed from the base of the PR and between f188c7a and 27520d6.

📒 Files selected for processing (9)
  • .changeset/honest-noninteractive-init.md
  • packages/cli/src/commands/impl/steps/handoff-claude.ts
  • packages/cli/src/commands/impl/steps/handoff-codex.ts
  • packages/cli/src/commands/init/__tests__/init-command.test.ts
  • packages/cli/src/commands/init/index.ts
  • packages/cli/src/commands/init/steps/__tests__/install-deps.test.ts
  • packages/cli/src/commands/init/steps/install-deps.ts
  • packages/cli/src/messages.ts
  • skills/stash-cli/SKILL.md

Comment thread packages/cli/src/commands/impl/steps/handoff-claude.ts
…ss (rc.2 M4)

Non-interactive `stash init` reported success for setups that didn't fully
complete. Three honesty gaps closed:

1. Version skew. A non-interactive run can't reconcile a `behind` skew (it
   won't mutate an install without consent), so instead of warning-and-
   proceeding — scaffolding against packages older than this CLI expects and
   then claiming success — it now REFUSES with a non-zero exit (CliExit(1))
   and the exact align command. The #661/#666 no-mutation principle is
   preserved (execSync still not called); only the post-warning action
   changes from proceed to fail. `ahead` skew stays a warn (install likely
   fine; update the CLI).

2. False 'Setup complete'. The summary header and the auth/db/scaffold
   checkmarks were unconditional. Now: when EQL is required but not installed
   (eqlInstalled=false AND integration !== prisma-next), the summary reads
   'Setup incomplete' and init exits non-zero, pointing at `stash eql install`.
   'Database connection verified' → 'Database URL resolved' (init resolves a
   URL, never opens a connection). 'Encryption client scaffolded' is shown
   only when a client was written (clientFilePath set; skipped for prisma-next).

3. False 'skills loaded'. The Claude/Codex handoff launch prompt referenced
   the skills dir unconditionally; a stripped build installs no skills, so it
   told the agent to read files that aren't there. The clause is now
   conditional on installSkills() actually copying something.

Tests: install-deps skew tests updated to assert the refusal (still never
mutates); new init-command honest-summary tests (EQL-missing → exit 1 +
'Setup incomplete'; prisma-next eqlInstalled=false → completes). Skill + doc
comments updated. Suite 542 unit / 62 e2e green, code:check clean. Changeset:
stash minor.

Claude-Session: https://claude.ai/code/session_01MxTTPaPP16m6br7Hoab94w
@coderdan
coderdan force-pushed the feat/honest-noninteractive-init branch from 27520d6 to fb77e14 Compare July 18, 2026 12:26
@coderdan
coderdan requested a review from Copilot July 18, 2026 15:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes stash init reliable for automation by ensuring non-interactive runs never report success when setup is incomplete or potentially inconsistent with the CLI’s expected runtime package versions.

Changes:

  • Make non-interactive init refuse (exit non-zero) on behind version skew instead of warning-and-proceeding.
  • Make the init summary truthful: “Database URL resolved” (not “connection verified”), “Setup incomplete” + exit non-zero when EQL is missing (except Prisma Next), and only reference skills when they were actually installed.
  • Update unit coverage, changeset, and the published stash-cli skill documentation to match the new behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
skills/stash-cli/SKILL.md Documents the new “fail on behind skew” and “setup incomplete” non-interactive behavior.
packages/cli/src/messages.ts Adds stable message leaders for non-interactive init failure modes.
packages/cli/src/commands/init/steps/install-deps.ts Refuses non-interactively on behind skew (throws CliExit(1)), while keeping ahead skew as warn-and-proceed.
packages/cli/src/commands/init/steps/tests/install-deps.test.ts Updates skew tests to assert refusal + no mutation in non-interactive mode.
packages/cli/src/commands/init/index.ts Adjusts checkmark copy, adds EQL-missing “Setup incomplete” gate + non-zero exit (except Prisma Next).
packages/cli/src/commands/init/tests/init-command.test.ts Adds unit tests asserting the honest-summary behavior and Prisma Next exception.
packages/cli/src/commands/impl/steps/handoff-codex.ts Makes the “skills” clause in the launch prompt conditional on actual skill installation.
packages/cli/src/commands/impl/steps/handoff-claude.ts Makes the “skills” clause in the launch prompt conditional on actual skill installation.
.changeset/honest-noninteractive-init.md Adds release notes describing the non-interactive honesty changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/cli/src/commands/init/index.ts Outdated
Two "only claim what actually happened" gaps found in review:

- Copilot: the "✓ Encryption client scaffolded" checkmark was gated on
  `state.clientFilePath`, which build-schema sets even when it KEEPS an existing
  file (writes nothing). Gate on `state.schemaGenerated` (true only when a
  placeholder was written); show "✓ Encryption client kept (existing file)" for
  the keep path. Prisma Next (no clientFilePath) still shows neither.

- CodeRabbit: the setup-prompt "Skills loaded" section pointed at skill
  directories and `AGENTS.md` regardless of what the handoff wrote — so a
  stripped build (no skills) sent the agent to read files that don't exist, and
  the Claude handoff (which never writes AGENTS.md) named it as the doctrine
  source. New `skillsLoadedLines(handoff, installedSkills)` renders the section
  honestly: no skills → point only at what was written (AGENTS.md for
  codex/agents-md, the docs for claude-code); claude-code → doctrine is in the
  installed skills, not AGENTS.md. Also hedged "list the skills loaded (if any)".

Added setup-prompt honesty tests (empty-skills × handoff) and de-duped the two
identical inline blocks. 557 tests green; build + biome clean.

Claude-Session: https://claude.ai/code/session_01MxTTPaPP16m6br7Hoab94w
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants